<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>增加同步功能</title>
</head>
<body>
<script>
    function HttpRequest(url, callback, async) {
        this.request = new XMLHttpRequest();
        this.request.open('GET', url, async);
        this.request.onreadystatechange = reqReadyStateChange;

        var that = this;

        function reqReadyStateChange() {
            if (that.request.readyState == 4) {
                if (that.request.status == 200) {
                    callback(that.request.responseText);
                } else {
                    alert('An error occurred trying to contact the server.');
                }
            }
        }
    }

    HttpRequest.prototype.send = function () {
        this.request.send(null);
    }
</script>
</body>
</html>